# -*- coding: utf-8 -*-
"""
这个文件夹可以封装写一个登录代码  后续用例指定登录 直接调用这个文件夹即可
"""
import allure
from selenium import webdriver
from base.WebKeys import WebKeys
from page.login_page.AIIPages import *


class LoginPage(WebKeys):
    """xl-登录流程"""

    def login(self,username,password):
        with allure.step("访问浏览器"):
            self.open("https://main.xlmall.cn/login/loginType")

        with allure.step("切换账号密码登录"):
            self.on_click(*Toggle_login)

        with allure.step(f"输入用户名{username}"):
            self.locator_with_wait(*username_loc).send_keys(username)

        with allure.step(f"输入密码{password}"):
            self.locator_with_wait(*password_loc).send_keys(password)

        with allure.step("点击登陆"):
            self.on_click(*loginbtn_loc)


    def get_result_true(self):
        login_assert = '//*/a[text()="退出登录"]'
        result=self.read(login_assert)
        # print(result)
        return result

    def get_result_text(self):
        login_assert_text = '//*[@id="ant-message"]/span/div/div/div[2]/span'
        result=self.read(login_assert_text)
        # print(result)
        return result




# # 浏览器可以放在conftest里面是不是
# if __name__ == '__main__':
#     login_page=LoginPage(webdriver.Chrome())
#     login_page.login("13465004020","zhd12345")
#     # login_page.get_result_true()
#     login_page.get_result_text()
#



